package com.itheima.Thread10;

public class MyThread extends Thread {
    private static int count = 100;
    private static Object obj = new Object();
    @Override
    public void run() {
        synchronized (obj){
            while(true){
                if(count ==0){
                    break;
                }else{
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    count--;
                    System.out.println(Thread.currentThread().getName()+"正在买票,还剩"+count+"张票");

                }
             }
        }
    }
}
